﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinForm1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void clickBtn(object sender, EventArgs e)
        {
            System.String num1 = this.number1.Text;
            double dNum1 = 0.0;
            try
            {
                dNum1 = System.Convert.ToDouble(num1);
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Convert fail");
            }

            System.String num2 = this.number2.Text;
            double dNum2 = 0.0;
            try
            {
                dNum2 = System.Convert.ToDouble(num2);
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Convert fail");
            }

            Calculate cal = new Calculate();
            cal.dA = dNum1;
            cal.dB = dNum2;
            double dTotal = cal.plus();

            System.String sTotal = System.Convert.ToString(dTotal);
            this.total.Text = sTotal;
        }

        private void onMouseDown(object sender, MouseEventArgs e)
        {
            System.String str = System.String.Format("X:{0:0.##},Y:{1:0.##}", e.X, e.Y);
            MessageBox.Show(str);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            // If there is an image and it has a location, 
            // paint it when the Form is repainted.
            base.OnPaint(e);
            IntPtr hwnd = Drawing.Handle;

            using (Graphics gfx = Graphics.FromHwnd(hwnd))
            {
                int x1 = 0;
                int y1 = 0;
                // Loop trough the 255 values red can have 
                for (int i = 0; i <= 255; i++)
                {
                    // Create new brush with a defined color 
                    Color brushColor = Color.FromArgb(i, 0, 0);
                    // The brush is solid because we want a solid rectangle 
                    SolidBrush myBrush = new SolidBrush(brushColor);
                    // Actually draw the rectangle 
                    gfx.FillRectangle(myBrush, x1, y1, 10, 10);
                    // The next rectangle should be near the last one 
                    x1 = x1 + 10;
                    // If the row is complete start another one 
                    if ((x1 % 290) == 0)
                    {
                        y1 = y1 + 10;
                        x1 = 0;
                    }
                }
                for (int i = 0; i <= 255; i++)
                {
                    Color brushColor = Color.FromArgb(0, i, 0);
                    SolidBrush myBrush = new SolidBrush(brushColor);
                    gfx.FillRectangle(myBrush, x1, y1, 10, 10);
                    x1 = x1 + 10;
                    if ((x1 % 290) == 0)
                    {
                        y1 = y1 + 10;
                        x1 = 0;
                    }
                }
                for (int i = 0; i <= 255; i++)
                {
                    Color brushColor = Color.FromArgb(0, 0, i);
                    SolidBrush myBrush = new SolidBrush(brushColor);
                    gfx.FillRectangle(myBrush, x1, y1, 10, 10);
                    x1 = x1 + 10;
                    if ((x1 % 290) == 0)
                    {
                        y1 = y1 + 10;
                        x1 = 0;
                    }
                }
            }
            // Get the graphics object 
            
            
        }
    }
}
